using System;using System.Data;using System.Data.SqlClient;using System.Collections.Generic;namespace MyWeb.Data{	public class ContactDAL : SqlDataProvider	{		#region[Contact_GetById]		public List<Contact> Contact_GetById(string Id)		{			var list = new List<Contact>();			using (var dbCmd = new SqlCommand("sp_Contact_GetById", GetConnection()))			{				var obj = new Data.Contact();				dbCmd.CommandType = CommandType.StoredProcedure;				dbCmd.Parameters.Add(new SqlParameter("@Id", Id));				var dr = dbCmd.ExecuteReader();				if (dr.HasRows)				{					while (dr.Read())					{						list.Add(obj.ContactIDataReader(dr));					}
                }
                dr.Close();
                //conn.Close();			}			return list;		}		#endregion		#region[Contact_GetByTop]		public List<Contact> Contact_GetByTop(string Top, string Where, string Order)		{			var list = new List<Data.Contact>();			using (var dbCmd = new SqlCommand("sp_Contact_GetByTop", GetConnection()))			{				var obj = new Data.Contact();				dbCmd.CommandType = CommandType.StoredProcedure;				dbCmd.Parameters.Add(new SqlParameter("@Top", Top));				dbCmd.Parameters.Add(new SqlParameter("@Where", Where));				dbCmd.Parameters.Add(new SqlParameter("@Order", Order));				var dr = dbCmd.ExecuteReader();				if (dr.HasRows)				{					while (dr.Read())					{						list.Add(obj.ContactIDataReader(dr));					}
                }
                dr.Close();
                //conn.Close();			}			return list;		}		#endregion		#region[Contact_GetByAll]		public List<Contact> Contact_GetByAll(string Lang)		{			var list = new List<Data.Contact>();			using (SqlCommand dbCmd = new SqlCommand("sp_Contact_GetByAll", GetConnection()))			{				var obj = new Data.Contact();				dbCmd.CommandType = CommandType.StoredProcedure;				dbCmd.Parameters.Add(new SqlParameter("@Lang", Lang));				var dr = dbCmd.ExecuteReader();				if (dr.HasRows)				{					while (dr.Read())					{						list.Add(obj.ContactIDataReader(dr));					}
                }
                dr.Close();
                //conn.Close();			}			return list;		}		#endregion		#region[Contact_Paging]		public List<Contact> Contact_Paging(string CurentPage, string PageSize, string Lang)		{			var list = new List<Data.Contact>();			using (SqlCommand dbCmd = new SqlCommand("sp_Contact_Paging", GetConnection()))			{				var obj = new Data.Contact();				dbCmd.CommandType = CommandType.StoredProcedure;				dbCmd.Parameters.Add(new SqlParameter("@CurentPage", CurentPage));				dbCmd.Parameters.Add(new SqlParameter("@PageSize", PageSize));				dbCmd.Parameters.Add(new SqlParameter("@Lang", Lang));				var dr = dbCmd.ExecuteReader();				if (dr.HasRows)				{					while (dr.Read())					{						list.Add(obj.ContactIDataReader(dr));					}
                }
                dr.Close();
                //conn.Close();			}		return list;		}		#endregion		#region[Contact_Insert]		public bool Contact_Insert(Contact data)		{			using (SqlCommand dbCmd = new SqlCommand("sp_Contact_Insert", GetConnection()))			{				dbCmd.CommandType = CommandType.StoredProcedure;				dbCmd.Parameters.Add(new SqlParameter("@Name", data.Name));				dbCmd.Parameters.Add(new SqlParameter("@Company", data.Company));				dbCmd.Parameters.Add(new SqlParameter("@Adress", data.Adress));				dbCmd.Parameters.Add(new SqlParameter("@Phone", data.Phone));
                dbCmd.Parameters.Add(new SqlParameter("@Mail", data.Mail));
                dbCmd.Parameters.Add(new SqlParameter("@Subject", data.Subject));				dbCmd.Parameters.Add(new SqlParameter("@Detail", data.Detail));				dbCmd.Parameters.Add(new SqlParameter("@Date", data.Date));				dbCmd.Parameters.Add(new SqlParameter("@Active", data.Active));				dbCmd.Parameters.Add(new SqlParameter("@Lang", data.Lang));				dbCmd.ExecuteNonQuery();			}			//Clear cache			System.Web.HttpContext.Current.Cache.Remove("Contact");			return true;		}		#endregion		#region[Contact_Update]		public bool Contact_Update(Contact data)		{			using (SqlCommand dbCmd = new SqlCommand("sp_Contact_Update", GetConnection()))			{				dbCmd.CommandType = CommandType.StoredProcedure;				dbCmd.Parameters.Add(new SqlParameter("@Id", data.Id));				dbCmd.Parameters.Add(new SqlParameter("@Name", data.Name));				dbCmd.Parameters.Add(new SqlParameter("@Company", data.Company));				dbCmd.Parameters.Add(new SqlParameter("@Adress", data.Adress));				dbCmd.Parameters.Add(new SqlParameter("@Phone", data.Phone));				dbCmd.Parameters.Add(new SqlParameter("@Mail", data.Mail));
                dbCmd.Parameters.Add(new SqlParameter("@Subject", data.Subject));				dbCmd.Parameters.Add(new SqlParameter("@Detail", data.Detail));				dbCmd.Parameters.Add(new SqlParameter("@Date", data.Date));				dbCmd.Parameters.Add(new SqlParameter("@Active", data.Active));				dbCmd.Parameters.Add(new SqlParameter("@Lang", data.Lang));				dbCmd.ExecuteNonQuery();			}			//Clear cache			System.Web.HttpContext.Current.Cache.Remove("Contact");			return true;		}		#endregion		#region[Contact_Delete]		public bool Contact_Delete(string Id)		{			using (SqlCommand dbCmd = new SqlCommand("sp_Contact_Delete", GetConnection()))			{				dbCmd.CommandType = CommandType.StoredProcedure;				dbCmd.Parameters.Add(new SqlParameter("@Id", Id));				dbCmd.ExecuteNonQuery();			}			//Clear cache			System.Web.HttpContext.Current.Cache.Remove("Contact");			return true;		}		#endregion			}}